<%--
  Created by IntelliJ IDEA.
  User: 飞蓬
  Date: 2018/4/20
  Time: 16:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <jsp:include page="../js_top.jsp"></jsp:include>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <style type="text/css">
        .table_report{width:540px;margin:15px auto;}
        .table_report tr td{line-height:31px;color:#63666d;font-size:14px;font-family:Arial,Helvetica,"微软雅黑";}
        .table_report tr td a{width:185px;height:38px;line-height:38px;-webkit-border-radius:5px;border-radius:5px;border-color:#b7bacb;display:block;font-size:14px;font-family:"微软雅黑";text-shadow:0 0px 0 rgba(0,0,0,0)!important;background:#b7bacb url(/static/img/images/table_report_icon1.png) no-repeat 70px center;text-align:center;color:#fff;cursor:pointer;text-indent:20px;float:left;margin:0 20px 0 0;}

        .table_report tr td a:hover,.table_report tr:last-child td:last-child a:hover{background-color:#0fb1d6;text-decoration:none;}
        input:focus:invalid:focus, textarea:focus:invalid:focus, select:focus:invalid:focus{border-color:#f59942;}
    </style>


</head>

<body>
<form action="" id="saveForm" name="saveForm" method="post">

    <table class="table  table-striped table-hover table_report">
        <tr>
            <input type="hidden" name="departmentid" id="departmentid" value="${department.departmentid}" />
            <input type="hidden" name="id" id="id" value="${hospital.id}" />
            <td >科室名称</td>
            <td><input type="text" name="departmentname" id="departmentname" value="${department.departmentname}" placeholder="必填"  required="true"/></td>
            <td>科室描述</td><td>
            <input type="text" name="departmentdescription" id="departmentdescription" value="${department.departmentdescription}" placeholder="选填"/></td>
        </tr>
        <tr>
            <td colspan="10">
                <a  style="margin-left: 66px"  href="javascript:save();">确定</a>
                <a href="javascript:top.Dialog.close();">取消</a>
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript">
    $(function($){
//  	var userId=$('#userId').val();
//  	if(userId !=null && userId != ""){
//  		$('#loginName').attr({readonly:"true"});
//  	};

    });
    function save(){
        var departmentname = $('#departmentname').val().trim();
        if(departmentname === null || departmentname === ''){
            $('#departmentname').tips({
                side:3,
                msg:'科室名不能为空！',
                bg:'#AE81FF',
                time:3
            });
            $('#departmentname').focus();
            return false;
        }

        var departmentid = '${hospital.departmentid}';
        if(departmentid == '' || departmentid == null || departmentid == undefined){
            $.ajax({
                cache: true,
                type: "POST",
                url:'<%=basePath%>hs/hospital/departmentSave.do',
                data:$('#saveForm').serialize(),
                async: false,
                error: function(request) {
                    layer.msg('<span style="color:white;">插入数据出错 !</span>');
                },
                success: function(data) {
                    if(data=true){
                        top.Dialog.close();
                    }else{
                        layer.msg('<span style="color:white;">插入数据出错 !</span>');
                    }
                }
            });
        }else{
            $.ajax({
                cache: true,
                type: "POST",
                url:'<%=basePath%>hs/hospital/departmentSave.do',
                data:$('#saveForm').serialize(),
                async: false,
                error: function(request) {
                    layer.msg('<span style="color:white;">更新数据出错 !</span>');
                },
                success: function(data) {
                    if(data=true){
                        top.Dialog.close();
                    }
                }
            });
        }


    }
</script>
</html>
